home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet multimedia / Muzyka / Edytory sampli (probek dzwieku) / ZynAddSubFX_2.2.0 / Setup_ZynAddSubFX-2.2.0.exe / source code / Params / ADnoteParameters.C next >
C/C++ Source or Header  |  2005-03-14  |  22KB  |  638 lines

  1. /*
  2.   ZynAddSubFX - a software synthesizer
  3.  
  4.   ADnoteParameters.C - Parameters for ADnote (ADsynth)
  5.   Copyright (C) 2002-2005 Nasca Octavian Paul
  6.   Author: Nasca Octavian Paul
  7.  
  8.   This program is free software; you can redistribute it and/or modify
  9.   it under the terms of version 2 of the GNU General Public License 
  10.   as published by the Free Software Foundation.
  11.  
  12.   This program is distributed in the hope that it will be useful,
  13.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.   GNU General Public License (version 2) for more details.
  16.  
  17.   You should have received a copy of the GNU General Public License (version 2)
  18.   along with this program; if not, write to the Free Software Foundation,
  19.   Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  20.  
  21. */
  22.  
  23. #include <stdlib.h>
  24. #include <stdio.h>
  25. #include <math.h>
  26.  
  27. #include "ADnoteParameters.h"
  28.  
  29. ADnoteParameters::ADnoteParameters(FFTwrapper *fft_):Presets(){
  30.     setpresettype("Padsyth");
  31.     fft=fft_;
  32.  
  33.     GlobalPar.FreqEnvelope=new EnvelopeParams(0,0);
  34.     GlobalPar.FreqEnvelope->ASRinit(64,50,64,60);
  35.     GlobalPar.FreqLfo=new LFOParams(70,0,64,0,0,0,0,0);
  36.     
  37.     GlobalPar.AmpEnvelope=new EnvelopeParams(64,1);
  38.     GlobalPar.AmpEnvelope->ADSRinit_dB(0,40,127,25);
  39.     GlobalPar.AmpLfo=new LFOParams(80,0,64,0,0,0,0,1);
  40.  
  41.     GlobalPar.GlobalFilter=new FilterParams(2,94,40);
  42.     GlobalPar.FilterEnvelope=new EnvelopeParams(0,1);
  43.     GlobalPar.FilterEnvelope->ADSRinit_filter(64,40,64,70,60,64);
  44.     GlobalPar.FilterLfo=new LFOParams(80,0,64,0,0,0,0,2);
  45.     GlobalPar.Reson=new Resonance();
  46.  
  47.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++) EnableVoice(nvoice);
  48.     
  49.     defaults();
  50. };
  51.  
  52. void ADnoteParameters::defaults(){
  53.     //Default Parameters
  54.     /* Frequency Global Parameters */
  55.     GlobalPar.PStereo=1;//stereo
  56.     GlobalPar.PDetune=8192;//zero
  57.     GlobalPar.PCoarseDetune=0;
  58.     GlobalPar.PDetuneType=1;
  59.     GlobalPar.FreqEnvelope->defaults();
  60.     GlobalPar.FreqLfo->defaults();
  61.     GlobalPar.PBandwidth=64;
  62.     
  63.     /* Amplitude Global Parameters */
  64.     GlobalPar.PVolume=90;
  65.     GlobalPar.PPanning=64;//center
  66.     GlobalPar.PAmpVelocityScaleFunction=64;
  67.     GlobalPar.AmpEnvelope->defaults();
  68.     GlobalPar.AmpLfo->defaults();
  69.     GlobalPar.PPunchStrength=0;
  70.     GlobalPar.PPunchTime=60;
  71.     GlobalPar.PPunchStretch=64;
  72.     GlobalPar.PPunchVelocitySensing=72;
  73.     GlobalPar.Hrandgrouping=0;
  74.     
  75.     /* Filter Global Parameters*/
  76.     GlobalPar.PFilterVelocityScale=64;
  77.     GlobalPar.PFilterVelocityScaleFunction=64;
  78.     GlobalPar.GlobalFilter->defaults();
  79.     GlobalPar.FilterEnvelope->defaults();
  80.     GlobalPar.FilterLfo->defaults();
  81.     GlobalPar.Reson->defaults();
  82.  
  83.  
  84.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
  85.     defaults(nvoice);
  86.     };
  87.     VoicePar[0].Enabled=1;
  88. };
  89.  
  90. /*
  91.  * Defaults a voice
  92.  */
  93. void ADnoteParameters::defaults(int n){
  94.     int nvoice=n;
  95.     VoicePar[nvoice].Enabled=0;
  96.     VoicePar[nvoice].Type=0;
  97.     VoicePar[nvoice].Pfixedfreq=0;
  98.     VoicePar[nvoice].PfixedfreqET=0;
  99.     VoicePar[nvoice].Presonance=1;
  100.     VoicePar[nvoice].Pfilterbypass=0;
  101.     VoicePar[nvoice].Pextoscil=-1;
  102.     VoicePar[nvoice].PextFMoscil=-1;
  103.     VoicePar[nvoice].Poscilphase=64;
  104.     VoicePar[nvoice].PFMoscilphase=64;
  105.     VoicePar[nvoice].PDelay=0;
  106.     VoicePar[nvoice].PVolume=100;
  107.     VoicePar[nvoice].PVolumeminus=0;
  108.     VoicePar[nvoice].PPanning=64;//center
  109.     VoicePar[nvoice].PDetune=8192;//8192=0
  110.     VoicePar[nvoice].PCoarseDetune=0;
  111.     VoicePar[nvoice].PDetuneType=0;
  112.     VoicePar[nvoice].PFreqLfoEnabled=0;
  113.     VoicePar[nvoice].PFreqEnvelopeEnabled=0;
  114.     VoicePar[nvoice].PAmpEnvelopeEnabled=0;
  115.     VoicePar[nvoice].PAmpLfoEnabled=0;
  116.     VoicePar[nvoice].PAmpVelocityScaleFunction=127;
  117.     VoicePar[nvoice].PFilterEnabled=0;
  118.     VoicePar[nvoice].PFilterEnvelopeEnabled=0;
  119.     VoicePar[nvoice].PFilterLfoEnabled=0;
  120.     VoicePar[nvoice].PFMEnabled=0;
  121.  
  122.     //I use the internal oscillator (-1)
  123.     VoicePar[nvoice].PFMVoice=-1;
  124.  
  125.     VoicePar[nvoice].PFMVolume=90;
  126.     VoicePar[nvoice].PFMVolumeDamp=64;
  127.     VoicePar[nvoice].PFMDetune=8192;
  128.     VoicePar[nvoice].PFMCoarseDetune=0;
  129.     VoicePar[nvoice].PFMDetuneType=0;
  130.     VoicePar[nvoice].PFMFreqEnvelopeEnabled=0;
  131.     VoicePar[nvoice].PFMAmpEnvelopeEnabled=0;
  132.     VoicePar[nvoice].PFMVelocityScaleFunction=64;    
  133.  
  134.     VoicePar[nvoice].OscilSmp->defaults();
  135.     VoicePar[nvoice].FMSmp->defaults();
  136.  
  137.     VoicePar[nvoice].AmpEnvelope->defaults();
  138.     VoicePar[nvoice].AmpLfo->defaults();
  139.  
  140.     VoicePar[nvoice].FreqEnvelope->defaults();
  141.     VoicePar[nvoice].FreqLfo->defaults();
  142.  
  143.     VoicePar[nvoice].VoiceFilter->defaults();
  144.     VoicePar[nvoice].FilterEnvelope->defaults();
  145.     VoicePar[nvoice].FilterLfo->defaults();
  146.  
  147.     VoicePar[nvoice].FMFreqEnvelope->defaults();
  148.     VoicePar[nvoice].FMAmpEnvelope->defaults();
  149. };
  150.  
  151.  
  152.  
  153. /*
  154.  * Init the voice parameters
  155.  */
  156. void ADnoteParameters::EnableVoice(int nvoice){
  157.     VoicePar[nvoice].OscilSmp=new OscilGen(fft,GlobalPar.Reson);
  158.     VoicePar[nvoice].FMSmp=new OscilGen(fft,NULL);
  159.  
  160.     VoicePar[nvoice].AmpEnvelope=new EnvelopeParams(64,1);
  161.     VoicePar[nvoice].AmpEnvelope->ADSRinit_dB(0,100,127,100);    
  162.     VoicePar[nvoice].AmpLfo=new LFOParams(90,32,64,0,0,30,0,1);
  163.  
  164.     VoicePar[nvoice].FreqEnvelope=new EnvelopeParams(0,0);
  165.     VoicePar[nvoice].FreqEnvelope->ASRinit(30,40,64,60);
  166.     VoicePar[nvoice].FreqLfo=new LFOParams(50,40,0,0,0,0,0,0);
  167.  
  168.     VoicePar[nvoice].VoiceFilter=new FilterParams(2,50,60);
  169.     VoicePar[nvoice].FilterEnvelope=new EnvelopeParams(0,0);
  170.     VoicePar[nvoice].FilterEnvelope->ADSRinit_filter(90,70,40,70,10,40);
  171.     VoicePar[nvoice].FilterLfo=new LFOParams(50,20,64,0,0,0,0,2);
  172.  
  173.     VoicePar[nvoice].FMFreqEnvelope=new EnvelopeParams(0,0);
  174.     VoicePar[nvoice].FMFreqEnvelope->ASRinit(20,90,40,80);
  175.     VoicePar[nvoice].FMAmpEnvelope=new EnvelopeParams(64,1);
  176.     VoicePar[nvoice].FMAmpEnvelope->ADSRinit(80,90,127,100);
  177. };
  178.  
  179. /*
  180.  * Get the Multiplier of the fine detunes of the voices
  181.  */
  182. REALTYPE ADnoteParameters::getBandwidthDetuneMultiplier(){
  183.     REALTYPE bw=(GlobalPar.PBandwidth-64.0)/64.0;
  184.     bw=pow(2.0,bw*pow(fabs(bw),0.2)*5.0);
  185.     
  186.     return(bw);
  187. };
  188.  
  189.  
  190. /*
  191.  * Kill the voice
  192.  */
  193. void ADnoteParameters::KillVoice(int nvoice){
  194.     delete (VoicePar[nvoice].OscilSmp);
  195.     delete (VoicePar[nvoice].FMSmp);
  196.  
  197.     delete (VoicePar[nvoice].AmpEnvelope);
  198.     delete (VoicePar[nvoice].AmpLfo);
  199.  
  200.     delete (VoicePar[nvoice].FreqEnvelope);
  201.     delete (VoicePar[nvoice].FreqLfo);
  202.  
  203.     delete (VoicePar[nvoice].VoiceFilter);
  204.     delete (VoicePar[nvoice].FilterEnvelope);
  205.     delete (VoicePar[nvoice].FilterLfo);
  206.  
  207.     delete (VoicePar[nvoice].FMFreqEnvelope);
  208.     delete (VoicePar[nvoice].FMAmpEnvelope);
  209. };
  210.  
  211. ADnoteParameters::~ADnoteParameters(){
  212.     delete(GlobalPar.FreqEnvelope);
  213.     delete(GlobalPar.FreqLfo);
  214.     delete(GlobalPar.AmpEnvelope);
  215.     delete(GlobalPar.AmpLfo);
  216.     delete(GlobalPar.GlobalFilter);
  217.     delete(GlobalPar.FilterEnvelope);
  218.     delete(GlobalPar.FilterLfo);
  219.     delete(GlobalPar.Reson);
  220.  
  221.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
  222.         KillVoice(nvoice);
  223.     };
  224. };
  225.  
  226.  
  227.  
  228.  
  229. void ADnoteParameters::add2XMLsection(XMLwrapper *xml,int n){
  230.     int nvoice=n;
  231.     if (nvoice>=NUM_VOICES) return;
  232.     
  233.     int oscilused=0,fmoscilused=0;//if the oscil or fmoscil are used by another voice
  234.  
  235.     for (int i=0;i<NUM_VOICES;i++){
  236.     if (VoicePar[i].Pextoscil==nvoice) oscilused=1;
  237.     if (VoicePar[i].PextFMoscil==nvoice) fmoscilused=1;
  238.     };
  239.     
  240.     xml->addparbool("enabled",VoicePar[nvoice].Enabled);
  241.     if (((VoicePar[nvoice].Enabled==0)&&(oscilused==0)&&(fmoscilused==0))&&(xml->minimal)) return;
  242.  
  243.     xml->addpar("type",VoicePar[nvoice].Type);
  244.     xml->addpar("delay",VoicePar[nvoice].PDelay);
  245.     xml->addparbool("resonance",VoicePar[nvoice].Presonance);
  246.     
  247.     xml->addpar("ext_oscil",VoicePar[nvoice].Pextoscil);
  248.     xml->addpar("ext_fm_oscil",VoicePar[nvoice].PextFMoscil);
  249.  
  250.     xml->addpar("oscil_phase",VoicePar[nvoice].Poscilphase);
  251.     xml->addpar("oscil_fm_phase",VoicePar[nvoice].PFMoscilphase);
  252.  
  253.     xml->addparbool("filter_enabled",VoicePar[nvoice].PFilterEnabled);
  254.     xml->addparbool("filter_bypass",VoicePar[nvoice].Pfilterbypass);
  255.  
  256.     xml->addpar("fm_enabled",VoicePar[nvoice].PFMEnabled);
  257.  
  258.     xml->beginbranch("OSCIL");
  259.     VoicePar[nvoice].OscilSmp->add2XML(xml);
  260.     xml->endbranch();
  261.  
  262.  
  263.     xml->beginbranch("AMPLITUDE_PARAMETERS");
  264.     xml->addpar("panning",VoicePar[nvoice].PPanning);
  265.         xml->addpar("volume",VoicePar[nvoice].PVolume);
  266.         xml->addparbool("volume_minus",VoicePar[nvoice].PVolumeminus);
  267.         xml->addpar("velocity_sensing",VoicePar[nvoice].PAmpVelocityScaleFunction);
  268.  
  269.     xml->addparbool("amp_envelope_enabled",VoicePar[nvoice].PAmpEnvelopeEnabled);
  270.     if ((VoicePar[nvoice].PAmpEnvelopeEnabled!=0)||(!xml->minimal)){
  271.         xml->beginbranch("AMPLITUDE_ENVELOPE");
  272.         VoicePar[nvoice].AmpEnvelope->add2XML(xml);
  273.         xml->endbranch();
  274.     };
  275.     xml->addparbool("amp_lfo_enabled",VoicePar[nvoice].PAmpLfoEnabled);
  276.     if ((VoicePar[nvoice].PAmpLfoEnabled!=0)||(!xml->minimal)){
  277.         xml->beginbranch("AMPLITUDE_LFO");
  278.         VoicePar[nvoice].AmpLfo->add2XML(xml);
  279.         xml->endbranch();
  280.     };
  281.     xml->endbranch();
  282.  
  283.     xml->beginbranch("FREQUENCY_PARAMETERS");
  284.     xml->addparbool("fixed_freq",VoicePar[nvoice].Pfixedfreq);
  285.     xml->addpar("fixed_freq_et",VoicePar[nvoice].PfixedfreqET);
  286.     xml->addpar("detune",VoicePar[nvoice].PDetune);
  287.     xml->addpar("coarse_detune",VoicePar[nvoice].PCoarseDetune);
  288.     xml->addpar("detune_type",VoicePar[nvoice].PDetuneType);
  289.  
  290.     xml->addparbool("freq_envelope_enabled",VoicePar[nvoice].PFreqEnvelopeEnabled);
  291.     if ((VoicePar[nvoice].PFreqEnvelopeEnabled!=0)||(!xml->minimal)){
  292.         xml->beginbranch("FREQUENCY_ENVELOPE");
  293.         VoicePar[nvoice].FreqEnvelope->add2XML(xml);
  294.         xml->endbranch();
  295.     };
  296.     xml->addparbool("freq_lfo_enabled",VoicePar[nvoice].PFreqLfoEnabled);
  297.     if ((VoicePar[nvoice].PFreqLfoEnabled!=0)||(!xml->minimal)){
  298.         xml->beginbranch("FREQUENCY_LFO");
  299.         VoicePar[nvoice].FreqLfo->add2XML(xml);
  300.         xml->endbranch();
  301.     };
  302.     xml->endbranch();
  303.  
  304.  
  305.     if ((VoicePar[nvoice].PFilterEnabled!=0)||(!xml->minimal)){
  306.     xml->beginbranch("FILTER_PARAMETERS");
  307.         xml->beginbranch("FILTER");
  308.         VoicePar[nvoice].VoiceFilter->add2XML(xml);
  309.         xml->endbranch();
  310.  
  311.         xml->addparbool("filter_envelope_enabled",VoicePar[nvoice].PFilterEnvelopeEnabled);
  312.         if ((VoicePar[nvoice].PFilterEnvelopeEnabled!=0)||(!xml->minimal)){
  313.         xml->beginbranch("FILTER_ENVELOPE");
  314.             VoicePar[nvoice].FilterEnvelope->add2XML(xml);
  315.         xml->endbranch();
  316.         };
  317.  
  318.         xml->addparbool("filter_lfo_enabled",VoicePar[nvoice].PFilterLfoEnabled);
  319.         if ((VoicePar[nvoice].PFilterLfoEnabled!=0)||(!xml->minimal)){
  320.         xml->beginbranch("FILTER_LFO");
  321.             VoicePar[nvoice].FilterLfo->add2XML(xml);
  322.         xml->endbranch();
  323.         };
  324.     xml->endbranch();
  325.     };
  326.  
  327.     if ((VoicePar[nvoice].PFMEnabled!=0)||(fmoscilused!=0)||(!xml->minimal)){
  328.     xml->beginbranch("FM_PARAMETERS");
  329.         xml->addpar("input_voice",VoicePar[nvoice].PFMVoice);
  330.  
  331.             xml->addpar("volume",VoicePar[nvoice].PFMVolume);
  332.             xml->addpar("volume_damp",VoicePar[nvoice].PFMVolumeDamp);
  333.             xml->addpar("velocity_sensing",VoicePar[nvoice].PFMVelocityScaleFunction);
  334.  
  335.         xml->addparbool("amp_envelope_enabled",VoicePar[nvoice].PFMAmpEnvelopeEnabled);
  336.         if ((VoicePar[nvoice].PFMAmpEnvelopeEnabled!=0)||(!xml->minimal)){
  337.         xml->beginbranch("AMPLITUDE_ENVELOPE");
  338.             VoicePar[nvoice].FMAmpEnvelope->add2XML(xml);
  339.         xml->endbranch();
  340.         };
  341.         xml->beginbranch("MODULATOR");
  342.             xml->addpar("detune",VoicePar[nvoice].PFMDetune);
  343.             xml->addpar("coarse_detune",VoicePar[nvoice].PFMCoarseDetune);
  344.             xml->addpar("detune_type",VoicePar[nvoice].PFMDetuneType);
  345.  
  346.         xml->addparbool("freq_envelope_enabled",VoicePar[nvoice].PFMFreqEnvelopeEnabled);
  347.         if ((VoicePar[nvoice].PFMFreqEnvelopeEnabled!=0)||(!xml->minimal)){
  348.             xml->beginbranch("FREQUENCY_ENVELOPE");
  349.             VoicePar[nvoice].FMFreqEnvelope->add2XML(xml);
  350.             xml->endbranch();
  351.         };
  352.  
  353.         xml->beginbranch("OSCIL");
  354.             VoicePar[nvoice].FMSmp->add2XML(xml);
  355.         xml->endbranch();
  356.  
  357.         xml->endbranch();
  358.     xml->endbranch();
  359.     };
  360. };
  361.  
  362.  
  363. void ADnoteParameters::add2XML(XMLwrapper *xml){
  364.     xml->addparbool("stereo",GlobalPar.PStereo);
  365.  
  366.     xml->beginbranch("AMPLITUDE_PARAMETERS");
  367.     xml->addpar("volume",GlobalPar.PVolume);
  368.     xml->addpar("panning",GlobalPar.PPanning);
  369.     xml->addpar("velocity_sensing",GlobalPar.PAmpVelocityScaleFunction);
  370.     xml->addpar("punch_strength",GlobalPar.PPunchStrength);
  371.     xml->addpar("punch_time",GlobalPar.PPunchTime);
  372.     xml->addpar("punch_stretch",GlobalPar.PPunchStretch);
  373.     xml->addpar("punch_velocity_sensing",GlobalPar.PPunchVelocitySensing);
  374.     xml->addpar("harmonic_randomness_grouping",GlobalPar.Hrandgrouping);
  375.     
  376.     xml->beginbranch("AMPLITUDE_ENVELOPE");
  377.         GlobalPar.AmpEnvelope->add2XML(xml);
  378.     xml->endbranch();
  379.     
  380.     xml->beginbranch("AMPLITUDE_LFO");
  381.         GlobalPar.AmpLfo->add2XML(xml);
  382.     xml->endbranch();
  383.     xml->endbranch();
  384.  
  385.     xml->beginbranch("FREQUENCY_PARAMETERS");
  386.     xml->addpar("detune",GlobalPar.PDetune);
  387.     
  388.     xml->addpar("coarse_detune",GlobalPar.PCoarseDetune);
  389.         xml->addpar("detune_type",GlobalPar.PDetuneType);
  390.  
  391.         xml->addpar("bandwidth",GlobalPar.PBandwidth);
  392.     
  393.     xml->beginbranch("FREQUENCY_ENVELOPE");
  394.         GlobalPar.FreqEnvelope->add2XML(xml);
  395.     xml->endbranch();
  396.     
  397.     xml->beginbranch("FREQUENCY_LFO");
  398.         GlobalPar.FreqLfo->add2XML(xml);
  399.     xml->endbranch();
  400.     xml->endbranch();
  401.     
  402.     
  403.     xml->beginbranch("FILTER_PARAMETERS");
  404.     xml->addpar("velocity_sensing_amplitude",GlobalPar.PFilterVelocityScale);
  405.     xml->addpar("velocity_sensing",GlobalPar.PFilterVelocityScaleFunction);
  406.     
  407.     xml->beginbranch("FILTER");
  408.         GlobalPar.GlobalFilter->add2XML(xml);
  409.     xml->endbranch();
  410.     
  411.     xml->beginbranch("FILTER_ENVELOPE");
  412.         GlobalPar.FilterEnvelope->add2XML(xml);
  413.     xml->endbranch();
  414.     
  415.     xml->beginbranch("FILTER_LFO");
  416.         GlobalPar.FilterLfo->add2XML(xml);
  417.     xml->endbranch();
  418.     xml->endbranch();
  419.     
  420.     xml->beginbranch("RESONANCE");
  421.         GlobalPar.Reson->add2XML(xml);
  422.     xml->endbranch();
  423.  
  424.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
  425.     xml->beginbranch("VOICE",nvoice);
  426.         add2XMLsection(xml,nvoice);
  427.     xml->endbranch();
  428.     };
  429. };
  430.  
  431.  
  432. void ADnoteParameters::getfromXML(XMLwrapper *xml){
  433.     GlobalPar.PStereo=xml->getparbool("stereo",GlobalPar.PStereo);
  434.     
  435.     if (xml->enterbranch("AMPLITUDE_PARAMETERS")){
  436.     GlobalPar.PVolume=xml->getpar127("volume",GlobalPar.PVolume);
  437.     GlobalPar.PPanning=xml->getpar127("panning",GlobalPar.PPanning);
  438.     GlobalPar.PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",GlobalPar.PAmpVelocityScaleFunction);
  439.  
  440.     GlobalPar.PPunchStrength=xml->getpar127("punch_strength",GlobalPar.PPunchStrength);
  441.     GlobalPar.PPunchTime=xml->getpar127("punch_time",GlobalPar.PPunchTime);
  442.     GlobalPar.PPunchStretch=xml->getpar127("punch_stretch",GlobalPar.PPunchStretch);
  443.     GlobalPar.PPunchVelocitySensing=xml->getpar127("punch_velocity_sensing",GlobalPar.PPunchVelocitySensing);
  444.     GlobalPar.Hrandgrouping=xml->getpar127("harmonic_randomness_grouping",GlobalPar.Hrandgrouping);
  445.     
  446.     if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
  447.         GlobalPar.AmpEnvelope->getfromXML(xml);
  448.         xml->exitbranch();
  449.     };
  450.     
  451.     if (xml->enterbranch("AMPLITUDE_LFO")){
  452.         GlobalPar.AmpLfo->getfromXML(xml);
  453.         xml->exitbranch();
  454.     };
  455.     
  456.       xml->exitbranch();
  457.     };
  458.  
  459.     if (xml->enterbranch("FREQUENCY_PARAMETERS")){
  460.     GlobalPar.PDetune=xml->getpar("detune",GlobalPar.PDetune,0,16383);
  461.     GlobalPar.PCoarseDetune=xml->getpar("coarse_detune",GlobalPar.PCoarseDetune,0,16383);
  462.         GlobalPar.PDetuneType=xml->getpar127("detune_type",GlobalPar.PDetuneType);
  463.  
  464.         GlobalPar.PBandwidth=xml->getpar127("bandwidth",GlobalPar.PBandwidth);
  465.     
  466.     xml->enterbranch("FREQUENCY_ENVELOPE");
  467.         GlobalPar.FreqEnvelope->getfromXML(xml);
  468.     xml->exitbranch();
  469.     
  470.     xml->enterbranch("FREQUENCY_LFO");
  471.         GlobalPar.FreqLfo->getfromXML(xml);
  472.     xml->exitbranch();
  473.  
  474.       xml->exitbranch();
  475.     };
  476.     
  477.     
  478.     if (xml->enterbranch("FILTER_PARAMETERS")){
  479.     GlobalPar.PFilterVelocityScale=xml->getpar127("velocity_sensing_amplitude",GlobalPar.PFilterVelocityScale);
  480.     GlobalPar.PFilterVelocityScaleFunction=xml->getpar127("velocity_sensing",GlobalPar.PFilterVelocityScaleFunction);
  481.     
  482.     xml->enterbranch("FILTER");
  483.         GlobalPar.GlobalFilter->getfromXML(xml);
  484.     xml->exitbranch();
  485.     
  486.     xml->enterbranch("FILTER_ENVELOPE");
  487.         GlobalPar.FilterEnvelope->getfromXML(xml);
  488.     xml->exitbranch();
  489.     
  490.     xml->enterbranch("FILTER_LFO");
  491.         GlobalPar.FilterLfo->getfromXML(xml);
  492.     xml->exitbranch();
  493.      xml->exitbranch();
  494.     };
  495.  
  496.     if (xml->enterbranch("RESONANCE")){
  497.     GlobalPar.Reson->getfromXML(xml);
  498.      xml->exitbranch();
  499.     };
  500.  
  501.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
  502.     VoicePar[nvoice].Enabled=0;
  503.     if (xml->enterbranch("VOICE",nvoice)==0) continue;
  504.         getfromXMLsection(xml,nvoice);
  505.     xml->exitbranch();
  506.     };
  507.     
  508.     
  509. };
  510.  
  511. void ADnoteParameters::getfromXMLsection(XMLwrapper *xml,int n){
  512.     int nvoice=n;
  513.     if (nvoice>=NUM_VOICES) return;
  514.  
  515.     VoicePar[nvoice].Enabled=xml->getparbool("enabled",0);
  516.  
  517.     VoicePar[nvoice].Type=xml->getpar127("type",VoicePar[nvoice].Type);
  518.     VoicePar[nvoice].PDelay=xml->getpar127("delay",VoicePar[nvoice].PDelay);
  519.     VoicePar[nvoice].Presonance=xml->getparbool("resonance",VoicePar[nvoice].Presonance);
  520.     
  521.     VoicePar[nvoice].Pextoscil=xml->getpar("ext_oscil",-1,-1,nvoice-1);
  522.     VoicePar[nvoice].PextFMoscil=xml->getpar("ext_fm_oscil",-1,-1,nvoice-1);
  523.  
  524.     VoicePar[nvoice].Poscilphase=xml->getpar127("oscil_phase",VoicePar[nvoice].Poscilphase);
  525.     VoicePar[nvoice].PFMoscilphase=xml->getpar127("oscil_fm_phase",VoicePar[nvoice].PFMoscilphase);
  526.  
  527.     VoicePar[nvoice].PFilterEnabled=xml->getparbool("filter_enabled",VoicePar[nvoice].PFilterEnabled);
  528.     VoicePar[nvoice].Pfilterbypass=xml->getparbool("filter_bypass",VoicePar[nvoice].Pfilterbypass);
  529.  
  530.     VoicePar[nvoice].PFMEnabled=xml->getpar127("fm_enabled",VoicePar[nvoice].PFMEnabled);
  531.  
  532.     if (xml->enterbranch("OSCIL")){
  533.     VoicePar[nvoice].OscilSmp->getfromXML(xml);
  534.      xml->exitbranch();
  535.     };
  536.  
  537.  
  538.     if (xml->enterbranch("AMPLITUDE_PARAMETERS")){
  539.     VoicePar[nvoice].PPanning=xml->getpar127("panning",VoicePar[nvoice].PPanning);
  540.     VoicePar[nvoice].PVolume=xml->getpar127("volume",VoicePar[nvoice].PVolume);
  541.         VoicePar[nvoice].PVolumeminus=xml->getparbool("volume_minus",VoicePar[nvoice].PVolumeminus);
  542.         VoicePar[nvoice].PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",VoicePar[nvoice].PAmpVelocityScaleFunction);
  543.  
  544.     VoicePar[nvoice].PAmpEnvelopeEnabled=xml->getparbool("amp_envelope_enabled",VoicePar[nvoice].PAmpEnvelopeEnabled);
  545.     if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
  546.         VoicePar[nvoice].AmpEnvelope->getfromXML(xml);
  547.         xml->exitbranch();
  548.     };
  549.  
  550.     VoicePar[nvoice].PAmpLfoEnabled=xml->getparbool("amp_lfo_enabled",VoicePar[nvoice].PAmpLfoEnabled);
  551.     if (xml->enterbranch("AMPLITUDE_LFO")){
  552.         VoicePar[nvoice].AmpLfo->getfromXML(xml);
  553.         xml->exitbranch();
  554.     };
  555.      xml->exitbranch();
  556.     };
  557.  
  558.     if (xml->enterbranch("FREQUENCY_PARAMETERS")){
  559.     VoicePar[nvoice].Pfixedfreq=xml->getparbool("fixed_freq",VoicePar[nvoice].Pfixedfreq);
  560.     VoicePar[nvoice].PfixedfreqET=xml->getpar127("fixed_freq_et",VoicePar[nvoice].PfixedfreqET);
  561.     
  562.     
  563.     VoicePar[nvoice].PDetune=xml->getpar("detune",VoicePar[nvoice].PDetune,0,16383);
  564.     
  565.     VoicePar[nvoice].PCoarseDetune=xml->getpar("coarse_detune",VoicePar[nvoice].PCoarseDetune,0,16383);
  566.     VoicePar[nvoice].PDetuneType=xml->getpar127("detune_type",VoicePar[nvoice].PDetuneType);
  567.  
  568.     VoicePar[nvoice].PFreqEnvelopeEnabled=xml->getparbool("freq_envelope_enabled",VoicePar[nvoice].PFreqEnvelopeEnabled);
  569.     if (xml->enterbranch("FREQUENCY_ENVELOPE")){
  570.         VoicePar[nvoice].FreqEnvelope->getfromXML(xml);
  571.         xml->exitbranch();
  572.     };
  573.  
  574.     VoicePar[nvoice].PFreqLfoEnabled=xml->getparbool("freq_lfo_enabled",VoicePar[nvoice].PFreqLfoEnabled);
  575.     if (xml->enterbranch("FREQUENCY_LFO")){
  576.         VoicePar[nvoice].FreqLfo->getfromXML(xml);
  577.         xml->exitbranch();
  578.     };
  579.      xml->exitbranch();
  580.     };
  581.  
  582.     if (xml->enterbranch("FILTER_PARAMETERS")){
  583.         if (xml->enterbranch("FILTER")){
  584.         VoicePar[nvoice].VoiceFilter->getfromXML(xml);
  585.             xml->exitbranch();
  586.         };
  587.  
  588.         VoicePar[nvoice].PFilterEnvelopeEnabled=xml->getparbool("filter_envelope_enabled",VoicePar[nvoice].PFilterEnvelopeEnabled);
  589.         if (xml->enterbranch("FILTER_ENVELOPE")){
  590.         VoicePar[nvoice].FilterEnvelope->getfromXML(xml);
  591.         xml->exitbranch();
  592.         };
  593.  
  594.         VoicePar[nvoice].PFilterLfoEnabled=xml->getparbool("filter_lfo_enabled",VoicePar[nvoice].PFilterLfoEnabled);
  595.         if (xml->enterbranch("FILTER_LFO")){
  596.         VoicePar[nvoice].FilterLfo->getfromXML(xml);
  597.         xml->exitbranch();
  598.         };
  599.     xml->exitbranch();
  600.     };
  601.  
  602.     if (xml->enterbranch("FM_PARAMETERS")){
  603.         VoicePar[nvoice].PFMVoice=xml->getpar("input_voice",VoicePar[nvoice].PFMVoice,-1,nvoice-1);
  604.  
  605.             VoicePar[nvoice].PFMVolume=xml->getpar127("volume",VoicePar[nvoice].PFMVolume);
  606.             VoicePar[nvoice].PFMVolumeDamp=xml->getpar127("volume_damp",VoicePar[nvoice].PFMVolumeDamp);
  607.             VoicePar[nvoice].PFMVelocityScaleFunction=xml->getpar127("velocity_sensing",VoicePar[nvoice].PFMVelocityScaleFunction);
  608.  
  609.         VoicePar[nvoice].PFMAmpEnvelopeEnabled=xml->getparbool("amp_envelope_enabled",VoicePar[nvoice].PFMAmpEnvelopeEnabled);
  610.         if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
  611.         VoicePar[nvoice].FMAmpEnvelope->getfromXML(xml);
  612.         xml->exitbranch();
  613.         };
  614.         
  615.         if (xml->enterbranch("MODULATOR")){
  616.             VoicePar[nvoice].PFMDetune=xml->getpar("detune",VoicePar[nvoice].PFMDetune,0,16383);
  617.             VoicePar[nvoice].PFMCoarseDetune=xml->getpar("coarse_detune",VoicePar[nvoice].PFMCoarseDetune,0,16383);
  618.             VoicePar[nvoice].PFMDetuneType=xml->getpar127("detune_type",VoicePar[nvoice].PFMDetuneType);
  619.  
  620.         VoicePar[nvoice].PFMFreqEnvelopeEnabled=xml->getparbool("freq_envelope_enabled",VoicePar[nvoice].PFMFreqEnvelopeEnabled);
  621.         if (xml->enterbranch("FREQUENCY_ENVELOPE")){
  622.             VoicePar[nvoice].FMFreqEnvelope->getfromXML(xml);
  623.             xml->exitbranch();
  624.         };
  625.  
  626.         if (xml->enterbranch("OSCIL")){
  627.             VoicePar[nvoice].FMSmp->getfromXML(xml);
  628.             xml->exitbranch();
  629.         };
  630.     
  631.            xml->exitbranch();
  632.         };
  633.     xml->exitbranch();
  634.     };
  635. };
  636.  
  637.  
  638.